package com.gitee.cashzhang27.test.boot.other.controller;

import cn.hutool.extra.mail.MailUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Cash Zhang
 * @version v1.0
 * @since 2019/05/14 10:07
 */
@RestController
@RequestMapping("mail")
public class MailTestController {

  @GetMapping("test1")
  public void test1(){
    MailUtil.send("cashzhang27@gmail.com", "测试", "邮件来自Hutool测试", false);
  }

  @GetMapping("/test2")
  public void test2() {
    List<String> paths = new ArrayList<>();
    paths.add("C:/Users/Administrator/Desktop/JavaInterviewGuide.md");
    List<File> fileList = new ArrayList<>();
    for (String path : paths) {
      File file = new File(path);
      fileList.add(file);
    }
    File[] files = new File[fileList.size()];
    fileList.toArray(files);
    MailUtil.send("cashzhang27@gmail.com", "测试", "邮件来自Hutool测试", false, files);
  }
}
